//泛型类

class GenericNumber<T> {
    public zeroValue!: T;
    public add!: (x: T, y: T) => T;
}

let myGenericNumber1 = new GenericNumber<number>();
myGenericNumber1.zeroValue = 0;
myGenericNumber1.add = function (x, y) { return x + y; };
console.log(myGenericNumber1.add(4,5));

let myGenericNumber2 = new GenericNumber<string>();
myGenericNumber2.zeroValue = "";
myGenericNumber2.add = function (x, y) { return x + y; };
console.log(myGenericNumber2.add("4","5"));